<?php


namespace app\index\model;


use think\Model;

class Study extends Model
{
    /**
     * 个人页，获取用户学历以及在校经历
     * ywh开发
     * @param $human
     * @return Study[]|\think\Collection
     */
    public function getStudyAttr($human){
        return $this
            ->join(['certificate' => 'certificate'],'study.user_id = certificate.user_id')
            ->field(['study.school','study.level','study.subject','study.school_time','study.out_school','study.in_school'])
            ->field(['certificate.certificate','certificate.mechanism','certificate.grade','certificate.is_check'])
            ->where('study.user_id','=',$human)
            ->select();
    }

    /**
     * 修改用户教育经历
     * ywh开发
     *
     * @param $human
     * @param $data
     * @return Study
     */
    public function upStudy($human,$data){
        return $this->where('user_id','=',$human)->update($data);
    }

    /**
     * 添加用户教育经历
     * ywh开发
     *
     * @param $data
     * @return bool
     */
    public function saveStudy($data){
        return $this->save($data);
    }
}